package com.hontech.pastacooking.model

import com.hontech.pastacooking.serial.UInt16
import com.hontech.pastacooking.serial.UInt32
import com.hontech.pastacooking.serial.UInt8

class WeightStatus {

    val appVersion = UInt16()
    val sensor = UInt8()
    val inside = UInt32()
    val external = UInt32()

    fun isInsideOk() = sensor.isSetBit(0)
    fun isExternOk() = sensor.isSetBit(1)
    fun isInsideExist() = sensor.isSetBit(2)
    fun isExternExist() = sensor.isSetBit(3)

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as WeightStatus

        if (appVersion != other.appVersion) return false
        if (sensor != other.sensor) return false
        if (inside != other.inside) return false
        if (external != other.external) return false

        return true
    }

    override fun hashCode(): Int {
        var result = appVersion.hashCode()
        result = 31 * result + sensor.hashCode()
        result = 31 * result + inside.hashCode()
        result = 31 * result + external.hashCode()
        return result
    }


}